# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=hunspell

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.3
pkgrel=1
pkgdesc="Spell checker and morphological analyzer library and program (mingw-w64)"
arch=('any')
url="http://hunspell.sourceforge.net/"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=(${MINGW_PACKAGE_PREFIX}-gcc-libs
        ${MINGW_PACKAGE_PREFIX}-gettext)
options=('!libtool' 'strip')
source=("http://download.sourceforge.net/${_realname}/${_realname}-$pkgver.tar.gz"
        "hunspell-1.3.2-canonicalhost.patch")
md5sums=('4967da60b23413604c9e563beacc63b4'
         'f8a5c0f3692a390d98daf0406da59cdf')

prepare() {
  cd "$srcdir/${_realname}-$pkgver"
  patch -Np1 -i "$srcdir/hunspell-1.3.2-canonicalhost.patch"
  
  autoreconf -fi
}

build() {

  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  
  ${srcdir}/${_realname}-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --disable-rpath \
    --enable-threads=posix \
    --without-ui \
    --without-readline
  
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
  cp ${pkgdir}${MINGW_PREFIX}/lib/lib${_realname}-${pkgver%.*}.dll.a ${pkgdir}${MINGW_PREFIX}/lib/lib${_realname}.dll.a
}
